{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "2fc1d783-eb3c-485a-8399-4417b937763a",
   "metadata": {},
   "source": [
    "Chapter 02\n",
    "\n",
    "# 热图可视化矩阵乘法\n",
    "《线性代数》 | 鸢尾花书：数学不难"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8725c185-542c-476e-98c9-db945cbf326b",
   "metadata": {},
   "source": [
    "这段代码的核心目标是执行两个矩阵 $A$ 和 $B$ 的矩阵乘法，并使用热图可视化矩阵的计算过程。矩阵乘法是线性代数的基础运算，在机器学习、统计建模和数据分析等领域具有广泛应用。\n",
    "\n",
    "---\n",
    "\n",
    "### 1. 生成随机矩阵\n",
    "\n",
    "首先，代码生成了两个随机矩阵 $A$ 和 $B$。  \n",
    "设 $A$ 为一个 $5 \\times 8$ 的矩阵，$B$ 为一个 $8 \\times 3$ 的矩阵。  \n",
    "其中，每个元素都是 $[0, 10)$ 之间的随机整数。  \n",
    "矩阵 $A$ 记作：\n",
    "$$\n",
    "A = \\begin{bmatrix} \n",
    "a_{1,1} & a_{1,2} & \\cdots & a_{1,8} \\\\ \n",
    "a_{2,1} & a_{2,2} & \\cdots & a_{2,8} \\\\ \n",
    "a_{3,1} & a_{3,2} & \\cdots & a_{3,8} \\\\ \n",
    "a_{4,1} & a_{4,2} & \\cdots & a_{4,8} \\\\ \n",
    "a_{5,1} & a_{5,2} & \\cdots & a_{5,8} \n",
    "\\end{bmatrix}\n",
    "$$\n",
    "矩阵 $B$ 记作：\n",
    "$$\n",
    "B = \\begin{bmatrix} \n",
    "b_{1,1} & b_{1,2} & b_{1,3} \\\\ \n",
    "b_{2,1} & b_{2,2} & b_{2,3} \\\\ \n",
    "\\vdots & \\vdots & \\vdots \\\\ \n",
    "b_{8,1} & b_{8,2} & b_{8,3} \n",
    "\\end{bmatrix}\n",
    "$$\n",
    "由于 $A$ 的列数（$8$）等于 $B$ 的行数（$8$），矩阵乘法 $C = A @ B$ 是可行的。\n",
    "\n",
    "---\n",
    "\n",
    "### 2. 计算矩阵乘法\n",
    "\n",
    "矩阵乘法的计算规则是：  \n",
    "$C$ 的每个元素 $c_{i,j}$ 由 $A$ 的第 $i$ 行与 $B$ 的第 $j$ 列的对应元素相乘后求和得到，即：\n",
    "$$\n",
    "C = A \\times B\n",
    "$$\n",
    "其具体计算公式如下：\n",
    "$$\n",
    "c_{i,j} = \\sum_{k=1}^{8} a_{i,k} \\cdot b_{k,j}\n",
    "$$\n",
    "其中：\n",
    "- $i$ 表示 $A$ 的行索引，取值范围 $1 \\leq i \\leq 5$\n",
    "- $j$ 表示 $B$ 的列索引，取值范围 $1 \\leq j \\leq 3$\n",
    "- $k$ 表示求和的索引，对应矩阵 $A$ 的列索引和矩阵 $B$ 的行索引\n",
    "\n",
    "因此，矩阵 $C$ 的大小为 $5 \\times 3$，即：\n",
    "$$\n",
    "C = \\begin{bmatrix} \n",
    "c_{1,1} & c_{1,2} & c_{1,3} \\\\ \n",
    "c_{2,1} & c_{2,2} & c_{2,3} \\\\ \n",
    "c_{3,1} & c_{3,2} & c_{3,3} \\\\ \n",
    "c_{4,1} & c_{4,2} & c_{4,3} \\\\ \n",
    "c_{5,1} & c_{5,2} & c_{5,3} \n",
    "\\end{bmatrix}\n",
    "$$\n",
    "其中每个元素 $c_{i,j}$ 是 $A$ 的第 $i$ 行与 $B$ 的第 $j$ 列的点积。\n",
    "\n",
    "---\n",
    "\n",
    "### 3. 可视化矩阵运算\n",
    "\n",
    "代码使用 **Seaborn** 的 `heatmap` 函数来可视化矩阵 $A$、$B$ 和 $C$，并在中间插入 \"=\" 和 \"@\" 符号，使整个图像直观地展示矩阵乘法的过程。\n",
    "\n",
    "#### 3.1 绘制矩阵 $C$\n",
    "首先，绘制矩阵 $C$ 的热图，颜色表示元素大小，并隐藏坐标轴标签：\n",
    "```python\n",
    "sns.heatmap(C, cmap='RdYlBu_r', xticklabels=[], yticklabels=[], cbar_kws={\"orientation\": \"horizontal\"})\n",
    "```\n",
    "\n",
    "#### 3.2 插入等号 \"=\"\n",
    "在第二个子图中插入一个等号 `=`，表示矩阵计算的等式。\n",
    "\n",
    "#### 3.3 绘制矩阵 $A$\n",
    "类似方法绘制矩阵 $A$ 的热图，并在子图标题中标记 \"A\"。\n",
    "\n",
    "#### 3.4 插入乘号 \"@\"\n",
    "在第四个子图中插入矩阵乘法的符号 `\"@\"`，表示矩阵 $A$ 与 $B$ 相乘。\n",
    "\n",
    "#### 3.5 绘制矩阵 $B$\n",
    "最后，在第五个子图中绘制矩阵 $B$ 的热图，并标记其标题为 \"B\"。\n",
    "\n",
    "---\n",
    "\n",
    "### 4. 结果存储\n",
    "最终，代码使用 `plt.savefig('AB heatmap.svg')` 将可视化结果保存为 `.svg` 文件，以便进一步查看或分享。\n",
    "\n",
    "---\n",
    "\n",
    "### 5. 代码总结\n",
    "- 生成两个随机整数矩阵 $A \\in \\mathbb{R}^{5 \\times 8}$ 和 $B \\in \\mathbb{R}^{8 \\times 3}$。\n",
    "- 计算矩阵乘积 $C = A @ B$，其大小为 $5 \\times 3$。\n",
    "- 使用 Seaborn 可视化矩阵 $A$、$B$ 和 $C$，并构建完整的计算表达式 $C = A @ B$ 的热图表示。\n",
    "\n",
    "这段代码完整地展示了矩阵乘法的计算规则以及其可视化表达，使得矩阵计算的结果更加直观。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7ef388a3-3216-401d-b913-a38c6652a924",
   "metadata": {},
   "source": [
    "## 初始化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "fd9660f1-a0f4-4d6e-b6a4-68075da36e37",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np  # 导入数值计算库\n",
    "import seaborn as sns  # 导入数据可视化库\n",
    "from matplotlib import pyplot as plt  # 导入绘图库"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c75a7adb-2019-49b3-8f2b-76c22408a82f",
   "metadata": {},
   "source": [
    "## 创建矩阵A和B"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "80cf47bc-909d-437f-b8e5-6caa26244a9d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[8, 0, 1, 4, 5, 1, 0, 5],\n",
       "       [0, 2, 1, 4, 7, 9, 7, 7],\n",
       "       [6, 6, 3, 1, 0, 8, 6, 0],\n",
       "       [0, 5, 7, 5, 3, 9, 5, 3],\n",
       "       [7, 3, 9, 3, 8, 5, 0, 6]])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.random.seed(88)  # 保证每次运行生成相同的随机数\n",
    "A = np.random.randint(0, 10, (5, 8))\n",
    "# 生成一个 5×12 的随机整数矩阵（数值范围 0~10）\n",
    "A"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "c2abb01d-1dc8-4dea-9f2d-10b24b87fb0c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Axes: >"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAhsAAAFhCAYAAADZdmiHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAUuklEQVR4nO3cbZCVBd3H8f/RxaMhoEDSMuDDqCOoiArGAD4NKkWOZTU+W5hj0yaWymi2+QJtwvWNT6kwoQ3JlNEL02gSFEekHNQUYkQk1KE7qJEhnxZj6FjLdb+S271R8Bj/c7F7Pp+ZM+NeZ/fa3zW7g9+59uxWiqIoAgAgyV5lDwAAejexAQCkEhsAQCqxAQCkEhsAQCqxAQCkEhsAQCqxAQCkEhsAQKqWsgd80Kvjjil7QkMd+dzqiIg4cdyskpc01ornroyIiLNvXFTyksb63czPR0TEW7X/KXdIgw2sHhoREcVbvyh3SINVBl4SEc37fd6s/6416/f5rriz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hHnvssSIiirVr15Y9ZZcqRVEU5WQOANAMmvI1GwBA44gNACCV2AAAUokNACCV2AAAUokNACCV2AAAUokNACCV2AAAUokNACCV2AAAUv0vY0bv/+ZPQ5QAAAAASUVORK5CYII=",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.heatmap(A, cmap = 'RdYlBu_r', square = True, \n",
    "            cbar = False,\n",
    "            linecolor = 'w', linewidths = 0.25)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "74af5fb8-b7b1-44cf-86a6-cf77b459a6c5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[4, 0, 2],\n",
       "       [2, 5, 9],\n",
       "       [2, 5, 6],\n",
       "       [6, 1, 1],\n",
       "       [8, 6, 1],\n",
       "       [2, 1, 7],\n",
       "       [4, 3, 6],\n",
       "       [6, 6, 0]])"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "B = np.random.randint(0, 10, (8, 3))\n",
    "# 生成一个 5×12 的随机整数矩阵（数值范围 0~10）\n",
    "B"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "25736e21-dc3f-40f6-bc50-2defffcedcfc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Axes: >"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAALYAAAGdCAYAAAC/7IlFAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAARN0lEQVR4nO3deWwU9f/H8dcCZUCk9QeNTQktmvATihDkknAUiIZqMSpGA+IRvCBF4BdsQF2roZg0C1EOwxWU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xtu3b1fHjh2TNofJS5GWLVuqT58+Kisri9hfVlamgQMHJmkq2zzP06RJk/TRRx9p8+bNuvnmm5M6j8kVW5IKCwv1+OOPq2/fvhowYIDefPNNVVZWqqCgINmjNeiPP/6I+KzMiooK7d+/X+3atVN2dnYSJ2vYxIkTtWrVKn388cdq27btxf9apqWlqXXr1pd/oKT8LeYyWbhwodepUyevZcuWXu/evZP2pyc/tmzZ4km6ZBs7dmyyR2tQXTNL8pYtW5aUefjfVmGSyWtsgLBhEmHDJMKGSYQNkwgbJhE2TCJsmETYMImwYRJhwyTChkn/D7Uh4rYdZj07AAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "sns.heatmap(B, cmap = 'RdYlBu_r', square = True, \n",
    "            cbar = False,\n",
    "            linecolor = 'w', linewidths = 0.25)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3e67d46c-576a-4420-b69b-b2e2c961df6e",
   "metadata": {},
   "source": [
    "## 矩阵乘法 A@B"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "3afce64c-060c-49f6-8303-7baa7425b83c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[130,  70,  38],\n",
       "       [174, 133, 140],\n",
       "       [ 88,  72, 177],\n",
       "       [134, 125, 188],\n",
       "       [180, 152, 141]])"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "C = A @ B\n",
    "C"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e2bc6c30-d23b-4610-96e7-4522ad5b850c",
   "metadata": {},
   "source": [
    "## 可视化矩阵乘法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "6c2f24c6-5be7-4cc7-b4be-00f2fa056b13",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAoA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uSlEwmde+99+rxxx/Xnj17NGzYMPXr10/Lly/XmjVr9NBDD6lr1656++23de6553pcPdpKv379mn0eiURUVlamq666yqOKMs9UAIRtDRf+tER+fn4bVwMgE5YuXapbbrlF4XBYklRWVqbZs2dr5syZ6tmzp6qqqnTPPfc0BoIzzzxT/fv31+rVqwmAp7CKigpdeOGFkupPDlVVVenWW29VIpHQ1KlTPa4uM0wFwE6dOukb3/iGampqvC4FHujQoYO+853vtOjYYNDU1ABOWVu3btWNN97Y+Pnjjz+uadOm6bbbbpMkDRo0SJs3b1YymWw8JicnRx999FHGa0XmXHjhhc0uArn66qv13nvv6a677tL3v/99nX766d4VlyGm/gYwEAjou9/9rjZu3KgdO3Z4XQ4ybO3atQqFQi16vPvuu16XCyANYrGYsrKyGj+vqalR7969mx1zySWXNPt8x44d6tSpU0bqw8nj4osv1uHDh7V161avS8kIc6c5pk2bpueee06TJk3Sn//858a3BRrEYjGtXLlSI0aM8KhCtBXeAgbsOfvss7V161YNGzZMUv3Zvc/+gtf0XaGtW7fq73//u8rLyzNZJk4Cb7zxhiSpc+fO3haSIeYCYP/+/fXYY49pypQpKioq0k9+8hNddNFFisViqq6u1vz581VYWEgAPAWddtppzU75Azj1FRcXq7KyUqWlpZKk0aNHa+bMmSosLNTFF1+sZ599VlVVVerXr59WrVqlH//4x5o6darOOeccbwtHm9q8eXPjHR92796tJUuWaNWqVbruuuvMXChq7kbQDd5880099NBDWr16tWpraxUKhXT++edrxIgRmjp1qpnfAADgVLZv3z716NFDc+fO1fjx4/Xpp5/q5ptv1tKlSyVJ5513nq699lr99re/VU5Oju68807dfvvt8vl83haONtFwI+imsrOzVVBQoB/84AeaMmXK594j+FRkNgACAGxYvHixbr75ZpWXl2v06NGSpF27dmnPnj369re/rb1792rfvn0qKCgg+MEMAiAA4JT3hz/8QT/60Y80ePBgTZo0SZdeeqk6duyovXv3Nv7N34EDB/SXv/yFEAgTCIAAABNqamo0c+ZMLVmyRHv27GncnpeXp3Hjxumuu+5S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9Y3wCJLa4C5+e9SMH36dNerV6/P3ZdMJl1ubq6bNWtW47YjR4647OxsN2/evFSGaRFJrqqqKqXx9+3b50KhkKusrGw85t///rfz+/1u5cqVaavFOefGjx/vrrnmmi9s01a1AOl06aWXusmTJzfbdsEFF7hf/OIXHlXUdr5sfQOssrIGWJz/KZ8B3LZtm/Lz81VQUKCxY8dq+/btkqSamhrV1taquLi48dhIJKIrr7xS69atS1de/UItGX/jxo2KxWLNjsnPz1dhYWGb1LhmzRp16dJF559/viZNmqRdu3Y17st0LUCq6urqtHHjxmavUUkqLi4+ZV+jX7S+ARZZWwOszf+UAmDfvn1VUVGh559/Xk888YRqa2s1YMAA7d69W7W1tZKknJycZm1ycnIa97WlloxfW1urcDisjh07tnmNQ4cO1TPPPKMXX3xRc+bM0YYNGzR48GBFo9GM1wK0xscff6xEIuHZnM60L1vfAIssrQEW538wlYOHDh3a+Lxnz57q37+/evToofLy8sYLHHw+X7M2zrnjtrWl1ozfFjWOGTOm8XlhYaH69Omj7t27a/ny5Ro1alRGawFOhNdzOlO+bH27/fbbPawM8JaFNcDi/D+h28C0b99ePXv21LZt2xqvlvnsbwW7du067reHttCS8XNzc1VXV6e9e/dmvMa8vDx1795d27Zt87wWoCU6deqkQCDg2Zz2WtP1DbDI8hpgYf6fUACMRqN66623lJeXp4KCAuXm5mrVqlWN++vq6rR27VoNGDDghAv9Ki0Zv6ioSKFQqNkxO3fu1ObNm9u8xt27d+uDDz5QXl6e57UALREOh1VUVNTsNSpJq1atMvEabbq+ARZZXgNMzP9Urhi544473Jo1a9z27dvdK6+84kpKStxpp53m3n33Xeecc7NmzXLZ2dluyZIlbtOmTe7GG290eXl57pNPPknLFSsHDhxw1dXVrrq62klyc+fOddXV1e69995r8fiTJ092Xbt2dS+88IJ7/fXX3eDBg12vXr1cPB5PWy0HDhxwd9xxh1u3bp2rqalxq1evdv3793dnnXVWm9QCtJXKykoXCoXcggUL3D//+U9XWlrq2rdv3zjnTyVftb4BFllZAyzO/5QC4JgxY1xeXp4LhUIuPz/fjRo1ym3ZsqVxfzKZdNOnT3e5ubkuEom4K664wm3atCltxa5evdpJOu4xfvz4Fo9/+PBhN3XqVHfGGWe4du3auZKSEvf++++ntZZDhw654uJi17lzZxcKhdzZZ5/txo8ff9w46aoFaEuPPPKI6969uwuHw653795u7dq1XpfUJr5qfQOssrAGWJz/Puec8+bcIwAAALzA/wIGAAAwhgAIAABgDAEQAADAGAIgAACAMQRAAAAAYwiAAAAAxhAAAQAAjCEAAgAAGEMABAAAMIYACAAAYAwBEAAAwBgCIAAAgDEEQAAAAGMIgAAAAMYQAAEAAIwhAAIAABhDAAQAADDm/wFezM+EY70uNQAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 800x300 with 8 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "fig, axs = plt.subplots(1, 5, figsize=(8, 3))  \n",
    "\n",
    "plt.sca(axs[0])\n",
    "ax = sns.heatmap(C, cmap='RdYlBu_r', \n",
    "                 xticklabels = [], yticklabels = [],\n",
    "                 cbar_kws={\"orientation\": \"horizontal\"})\n",
    "ax.set_aspect(\"equal\")\n",
    "plt.title('C')\n",
    "\n",
    "plt.sca(axs[1])\n",
    "plt.title('=')  # 绘制等号\n",
    "plt.axis('off')\n",
    "\n",
    "plt.sca(axs[2])\n",
    "ax = sns.heatmap(A, cmap='RdYlBu_r', \n",
    "                 xticklabels = [], yticklabels = [],\n",
    "                 cbar_kws={\"orientation\": \"horizontal\"})\n",
    "ax.set_aspect(\"equal\")\n",
    "plt.title('A')\n",
    "\n",
    "plt.sca(axs[3])\n",
    "plt.title('@')  # 绘制乘号\n",
    "plt.axis('off')\n",
    "\n",
    "plt.sca(axs[4])\n",
    "ax = sns.heatmap(B, cmap='RdYlBu_r', \n",
    "                 xticklabels = [], yticklabels = [],\n",
    "                 cbar_kws={\"orientation\": \"horizontal\"})\n",
    "ax.set_aspect(\"equal\")\n",
    "plt.title('B')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6b337590-b7f4-4a1e-8bac-04778a17db42",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "70ea153e-eb1e-4230-9cb8-343c9e4d298f",
   "metadata": {},
   "source": [
    "作者\t**生姜DrGinger**  \n",
    "脚本\t**生姜DrGinger**  \n",
    "视频\t**崔崔CuiCui**  \n",
    "开源资源\t[**GitHub**](https://github.com/Visualize-ML)  \n",
    "平台\t[**油管**](https://www.youtube.com/@DrGinger_Jiang)\t\t\n",
    "\t\t[**iris小课堂**](https://space.bilibili.com/3546865719052873)\t\t\n",
    "\t\t[**生姜DrGinger**](https://space.bilibili.com/513194466)  "
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:base] *",
   "language": "python",
   "name": "conda-base-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
